﻿Shader "Custom/SideBySideStereoImage"
{
	Properties
	{
		_LCamTex("LeftCameraTexture", 2D) = "white" {}
		_RCamTex("RightCameraTexture", 2D) = "white" {}
		_ScreenWidth("ScreenWidth", float) = 1920
		_ScreenHeight("ScreenHeight", float) = 1080
	}
		SubShader
	{
		// No culling or depth
		Cull Off ZWrite Off ZTest Always

		Pass
	{
		CGPROGRAM
#pragma vertex vert
#pragma fragment frag

#include "UnityCG.cginc"

		struct appdata
	{
		float4 vertex : POSITION;
		float2 uv : TEXCOORD0;
	};

	struct v2f
	{
		float2 uv : TEXCOORD0;
		float4 vertex : SV_POSITION;
	};

	v2f vert(appdata v)
	{
		v2f o;
		o.vertex = UnityObjectToClipPos(v.vertex);
		o.uv = v.uv;
		return o;
	}

	sampler2D _LCamTex;
	sampler2D _RCamTex;
	float _ScreenWidth;
	float _ScreenHeight;

	fixed4 frag(v2f i) : SV_Target
	{
		fixed4 col;
		//float width = 1920;
		//float height = 1152.0;

		 //左右格式
		if(i.uv.x<0.5)
			col = tex2D(_LCamTex, float2(i.uv.x, i.uv.y));
		else
			col = tex2D(_RCamTex, float2(i.uv.x-0.5, i.uv.y));
		return col;

		//float4 Color1,Color2;
		////Color2 = tex2D(_LCamTex, i.uv);
		//Color2 = tex2D(_LCamTex, float2(i.uv.x/2, i.uv.y));

		////Color1 = tex2D(_RCamTex, i.uv);
		//Color1 = tex2D(_RCamTex, float2(i.uv.x/2, i.uv.y));

		//Color1.r = Color2.r;
		//Color1.g = Color1.g;
		//Color1.b = Color1.b;
		//Color1.a = 1;//max(Color1.a, Color2.a);

		//return Color1; 


	}
		ENDCG
	}
	}
}
